class ContentTag < Liquid::Tag
  def initialize(tag_name, content_name, tokens)
    super
    @content_name = content_name
  end

  def render(context)
    content = Content.find_by_name(@content_name.to_s)
    unless content.blank?
      content.html.to_s.html_safe unless content.blank?
    else
      return "Text \"#{@content_name}\" nebyl nalezen."
    end
  end

  Liquid::Template.register_tag('get_content', ContentTag)
end
